import { defineConfig } from '@tsslint/config';
import { defineRules } from '@tsslint/eslint';

export default defineConfig([{
	rules: {
		...await defineRules({
			// oxlint's default rules, but without unicorn. See https://oxc.rs/docs/guide/usage/linter/rules.html
			'for-direction': true,
			'no-async-promise-executor': true,
			'no-caller': true,
			'no-class-assign': true,
			'no-compare-neg-zero': true,
			'no-cond-assign': true,
			'no-const-assign': true,
			'no-constant-binary-expression': true,
			'no-constant-condition': true,
			'no-control-regex': true,
			'no-debugger': true,
			'no-delete-var': true,
			'no-dupe-class-members': true,
			'no-dupe-else-if': true,
			'no-dupe-keys': true,
			'no-duplicate-case': true,
			'no-empty-character-class': true,
			'no-empty-pattern': true,
			'no-empty-static-block': true,
			'no-eval': true,
			'no-ex-assign': true,
			'no-extra-boolean-cast': true,
			'no-func-assign': true,
			'no-global-assign': true,
			'no-import-assign': true,
			'no-invalid-regexp': true,
			'no-irregular-whitespace': true,
			'no-loss-of-precision': true,
			'no-new-native-nonconstructor': true,
			'no-nonoctal-decimal-escape': true,
			'no-obj-calls': true,
			'no-self-assign': true,
			'no-setter-return': true,
			'no-shadow-restricted-names': true,
			'no-sparse-arrays': true,
			'no-this-before-super': true,
			'no-unassigned-vars': true,
			'no-unsafe-finally': true,
			'no-unsafe-negation': true,
			'no-unsafe-optional-chaining': true,
			'no-unused-labels': true,
			'no-unused-private-class-members': true,
			// 'no-unused-vars': true,
			'no-useless-backreference': true,
			'no-useless-catch': true,
			'no-useless-escape': true,
			'no-useless-rename': true,
			'no-with': true,
			'require-yield': true,
			'use-isnan': true,
			'valid-typeof': true,
			'@typescript-eslint/await-thenable': true,
			'@typescript-eslint/no-array-delete': true,
			'@typescript-eslint/no-base-to-string': true,
			// '@typescript-eslint/no-confusing-void-expression': true,
			'@typescript-eslint/no-duplicate-enum-values': true,
			'@typescript-eslint/no-duplicate-type-constituents': true,
			'@typescript-eslint/no-extra-non-null-assertion': true,
			// '@typescript-eslint/no-floating-promises': true,
			'@typescript-eslint/no-for-in-array': true,
			'@typescript-eslint/no-implied-eval': true,
			'@typescript-eslint/no-meaningless-void-operator': true,
			'@typescript-eslint/no-misused-new': true,
			'@typescript-eslint/no-misused-spread': true,
			'@typescript-eslint/no-non-null-asserted-optional-chain': true,
			// '@typescript-eslint/no-redundant-type-constituents': true,
			'@typescript-eslint/no-this-alias': true,
			'@typescript-eslint/no-unnecessary-parameter-property-assignment': true,
			'@typescript-eslint/no-unsafe-declaration-merging': true,
			'@typescript-eslint/no-unsafe-unary-minus': true,
			'@typescript-eslint/no-useless-empty-export': true,
			'@typescript-eslint/no-wrapper-object-types': true,
			'@typescript-eslint/prefer-as-const': true,
			'@typescript-eslint/require-array-sort-compare': true,
			'@typescript-eslint/restrict-template-expressions': true,
			'@typescript-eslint/triple-slash-reference': true,
			// '@typescript-eslint/unbound-method': true,

			// Project-specific rules
			'curly': true,
			'eqeqeq': true,
			'no-unused-expressions': true,
			'require-await': true,
			'@typescript-eslint/consistent-type-imports': [{
				disallowTypeAnnotations: false,
				fixStyle: 'inline-type-imports',
			}],
			'@typescript-eslint/no-unnecessary-type-assertion': true,
		}),
		'missing-dependency': (await import('./lint/missing-dependency-rule.js')).default,
		'type-imports': (await import('./lint/type-imports-rule.js')).default,
	},
}, {
	include: [
		'packages/language-core/**/*.ts',
		'packages/language-plugin-pug/**/*.ts',
		'packages/tsc/**/*.ts',
	],
	rules: {
		'typescript-services-types': (await import('./lint/typescript-services-types-rule.js')).default,
	},
}]);
